package com.yinhechuangji.application;

import com.alibaba.druid.pool.DruidDataSource;
import com.yinhechuangji.application.dao.BmAreaUserMapper;
import com.yinhechuangji.application.entity.BmAreaUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.sql.DataSource;
import java.sql.SQLException;

/**
 * @Auther: yaodx
 * @Date: 2018/8/7 11:53
 * @Description:
 */
@RestController
@RefreshScope
public class DemoController {
//    @Value("${name}")
//    private String profile;
    @Value("${spring.datasource.password}")
    private String password;

    @Autowired
    private DataSource dataSource;

    @Autowired
    private BmAreaUserMapper bmAreaUserMapper;

//    @Resource(name = "123456")
//    private DataSource hahaha;

//    @GetMapping("/test1")
//    public String test1(){
//        System.err.println("*******"+profile);
//        return profile;
//    }
    @GetMapping("/test2")
    public DataSource test2()throws SQLException{
        return dataSource;
    }
    @GetMapping("/test3")
    public String test3(){
        return password;
    }
    @GetMapping("/test4")
    public BmAreaUser test4(){
        BmAreaUser bmAreaUser=bmAreaUserMapper.selectByPk(1l);
        System.err.println(bmAreaUser);
        return bmAreaUser;
    }



}
